package com.prj.ufdm.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.prj.ufdm.web.bpo.SysFunctionBPO;
import com.prj.ufdm.web.bpo.SysUserBPO;
import com.prj.ufdm.web.enums.WebRetCodeEnum;
import com.prj.ufdm.web.model.SysFunction;
import com.prj.ufdm.web.model.SysUser;
import com.prj.ufdm.core.dto.RetData;
import com.prj.ufdm.core.exception.BaseException;

/**
 * 用户管理控制类
 * @author 胡义振  
 * @date 2018年3月26日
 */
@RequestMapping(value = "/api/test")
@Controller
public class SysUserController {
	
	@Autowired
	SysUserBPO sysUserBPO;
	
	@Autowired
	SysFunctionBPO sysFunctionBPO;
	
	@RequestMapping(value = "/t1")
	@ResponseBody
	public RetData<SysUser> t1(String token) throws Exception {
		if(token==null || token.equals("")) {
			throw new BaseException(WebRetCodeEnum.RET_CODE_0801008.getCode(),WebRetCodeEnum.RET_CODE_0801008.getMessage());
		}
		RetData<SysUser> retData = new RetData<SysUser>();
		retData.setRetBody(sysUserBPO.doGetSysUserByToken(token));
		return retData;
	}
	
	@RequestMapping(value = "/t2")
	@ResponseBody
	public RetData<List<SysFunction>> t2() throws Exception {
		RetData<List<SysFunction>> retData = new RetData<List<SysFunction>>();
		List<SysFunction> listSysFunction = sysFunctionBPO.doGetFunctionList();
		retData.setRetBody(listSysFunction);
		return retData;
	}
	
}
